<?php
$msg = ''; 
include('connection/connection.php');
include('header.php'); 
include('menu.php');
$loginid=$_SESSION['loginid'];
if(isset($_POST['submit']))
{
	$loginid=$_SESSION['loginid'];
	//$login_id=$_POST['login_id'];
	$old_password=$_POST['old_password'];
	$new_password=$_POST['new_password'];
	$old_password=$_POST['old_password'];
	$confirm_new_password=$_POST['confirm_new_password'];
	$q="SELECT password FROM tbl_lookup_user where login_id='$loginid'";
	$r=mysql_query($q);
	$x=mysql_fetch_array($r);
	$pass=$x['password'];
	if($old_password == $pass)
	{
	$qry="UPDATE tbl_lookup_user SET password='$new_password' where login_id='$loginid' AND password='$old_password'";
	$qry;
	$rec=mysql_query($qry);
	if($rec)
	{
		//header('Location:questionnaire2_4.php');
		//echo "Password Change successfully";
		$msg='<span class="successmssg"><b>Congratulation!!</b><br/>Your Password has Changed Successfully. Now you can go on <a href="home.php">Home</a> page</span>';
				
	}
	}
	else
	{
		$msg='<span class="successmssg"><b>Sorry!!</b><br/>Your Old Password is incorrcet, please try again.</span>';
	}
}
?>		
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Create User</title>
<script language="javascript" type="text/javascript" src="js/validate.js"></script>
</head>
<body>
<div align="right"><?php echo $msg;?></div>
<form action="" method="post" name="cp" id="cp" onSubmit="return changepass()">
<table width="786" height="39%" border="0" cellspacing="1"  id="table21" style=" padding:10px" >
<tr><td colspan="4" bgcolor="#C5D8EB" height="25" align="center">
<font face="Verdana" color="#006699" style="font-size: 8.5pt"><b>&nbsp;CHANGE PASSWORD</b></font></td>	
</tr>

<tr bgcolor="#eeeeee"><td height="26" colspan="4" bgcolor="#eeeeee">&nbsp;</td>
	<tr bgcolor="#eeeeee">
	<td width="119" height="25">&nbsp;</td>
	<td width="261"><font style="font-size: 8.5pt" face="Verdana" color="#000000">Login Id</font>	  </td> 
<td width="251">
											<input type="text" name="loginid" id="loginid" size="38" value="<?php echo $loginid ?>" readonly style="font-size: 8pt; font-family: Verdana; border:1px solid black;  border-width: 1px">
	  </td>
										<td width="111">&nbsp;</td>
	</tr>
									<tr bgcolor="#eeeeee">
										<td width="119" height="23">&nbsp;</td>
										<td width="261">
											<font face="Verdana" style="font-size: 8.5pt" color="#000000">Old Password</font>										</td>
										<td>
											<input type="password" name="old_password" id="old_password" size="38" style="font-size: 8pt; font-family: Verdana; border:1px solid black;  border-width: 1px">
										</td>
										<td width="111">&nbsp;</td>
									</tr>
									<tr bgcolor="#eeeeee">
										<td width="119" height="24">&nbsp;</td>
										<td width="261">
											<font style="font-size: 8.5pt" face="Verdana" color="#000000">New Password</font>										</td>
										<td>
											<input type="password" name="new_password" id="new_password" size="38" style="font-size: 8pt; font-family: Verdana; border:1px solid black;  border-width: 1px">
										</td>
										<td width="111">&nbsp;</td>
									</tr>
									<tr bgcolor="#eeeeee">
										<td width="119" height="25">&nbsp;</td>
										<td width="261">								
											<font face="Verdana" style="font-size: 8.5pt" color="#000000">Confirm New Password</font>										</td>
										<td>
											<input type="password" name="confirm_new_password" id="confirm_new_password" size="38" style="font-size: 8pt; font-family: Verdana; border:1px solid black;  border-width: 1px">
										</td>
										<td width="111">&nbsp;</td>
									</tr>
									
									<tr bgcolor="#eeeeee">
										<td width="119" height="31">&nbsp;</td>
										<td width="261">&nbsp;</td>
										<td>
											<input type="submit" value="Change Password" name="submit" style="border:1px solid #000000; font-size: 8pt; font-family: Verdana; ">
										</td>
										<td width="111">&nbsp;</td>
									</tr>
					
											
										</tr>
  </table>
								
</form>
					

</body>
</html>
